// Additive_Expression.cpp: implementation of the Additive_Expression class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Expression.h"
#include "Additive_Expression.h"
#include "Term.h"
#include "Addop.h"
#include "_Additive_Expression.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

Additive_Expression::Additive_Expression()
{
}

Additive_Expression::~Additive_Expression()
{
	delete m_pOperatorNote;
}

BOOL Additive_Expression::Interpret()
{
	_Additive_Expression *pExpression = NULL;
	return DualityOperIterpret<Term, Additive_Expression, _Additive_Expression>(pExpression, this, 2 , CString(_T("+")), CString(_T("-")));
/*	ComplierNote* pNote = new Term;
	if(!pNote->Interpret())
	{
		delete pNote;
		return FALSE;
	}
	
	CString strTemp;
	strTemp = AAnalyzer()->GetCurSymbol();
	if(strTemp == _T("+") || strTemp == _T("-"))
	{
		RemoveDualityOperLeftRecursion * pExpression = new _Additive_Expression;
		pExpression->AAnalyzer(AAnalyzer());
		if(!pExpression->Interpret())
		{
			delete pExpression;
			return FALSE;
		}
		
		ComplierNote* pTemp = GenerateAnalyzerTree<Additive_Expression>(pNote, pExpression);
		pTemp->SetOwner(this);
		LeftNote(pTemp);
		delete pExpression;
		return TRUE;
	}

	pNote->SetOwner(this);
	LeftNote(pNote);
	return TRUE;*/
}

Variable Additive_Expression::Execute()
{
	if(m_pOperatorNote != NULL)
	{
		return m_pOperatorNote->Execute();
	}
	else
	{
		return LeftNote()->Execute();
	}
}
